#include "0105.h"

//缺省参数不能在定义与声明中同时出现
//只能在声明中出现

/*
int main() {
    func();
    func(8);
    return 0;
}
*/

//引用
//期望形参的改变影响实参
/*
void Swap(int& a, int& b){
    int tmp = a;
    a = b;
    b = tmp;
}

int main(){
    int i = 0;
    int& k = i;
    int j = i;
    cout << &i << endl;
    cout << &k << endl;
    cout << &j << endl;
    ++k;
    cout << i << endl;
    cout << j << endl;
    Swap(i,j);
    cout << i << endl;
    cout << j << endl;
}
*/

typedef struct Node {
    struct Node *next;
    int val;
}*PNode;

//之前改变指针需要传二级指针
void PushBack1(Node** pHead, int x){
    Node* newNode = (Node*) malloc(sizeof( Node));
    if (*pHead == nullptr)
        *pHead = newNode;
}

void PushBack(Node*& pHead, int x){
    Node* newNode = (Node*) malloc(sizeof( Node));
    if (pHead == nullptr)
        pHead = newNode;
}

void PushBack2(PNode& pHead, int x){
    Node* newNode = (Node*) malloc(sizeof( Node));
    if (pHead == nullptr)
        pHead = newNode;
}